<template>
  <div class="projectQa-container" style="height:auto">
    <el-card>
    <p style="text-align: center;font-size: 24pt;font-weight:bold">Questionnaire</p>
    <p> &nbsp;</p>
    <el-card>
      <template #header>
        <div class="card-header">
          <span style="font-weight: bold">Warehouse</span>
        </div>
      </template>
      <el-row :gutter="20">
        <el-col :span="8">
          <div class="grid-content">
            <span class="label">Length</span>
            <el-input class="custom-input" v-model="warehouse.length" placeholder="Please input" style="width: 100px"></el-input>
            <span class="unit">M</span>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="grid-content">
            <span class="label">Width</span>
            <el-input class="custom-input" v-model="warehouse.width" placeholder="Please input" style="width: 100px"></el-input>
            <span class="unit">M</span>
          </div>
        </el-col>
      </el-row>
    </el-card>

    <!-- Goods Size Section -->
    <el-card>
      <template #header>
        <div class="card-header">
          <span style="font-weight: bold">Item</span>
        </div>
      </template>
      <el-row :gutter="20">
        <el-col :span="8">
          <div class="grid-content">
            <span class="label">Length</span>
            <el-select v-model="goodsSize.length"  style="width: 100px;">
              <el-option label="55" :value=55></el-option>
              <el-option label="65" :value=65></el-option>
            </el-select>
            <span class="unit">CM</span>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="grid-content">
            <span class="label">Width</span>
            <el-select v-model="goodsSize.width"  style="width: 100px;">
              <el-option label="55" :value=55></el-option>
              <el-option label="65" :value=65></el-option>
            </el-select>
            <span class="unit">CM</span>
          </div>
        </el-col>
      </el-row>
    </el-card>

    <!-- Expected Throughput Section -->
    <el-card >
      <template #header>
        <div class="card-header">
          <span style="font-weight: bold">Productivity</span>
        </div>
      </template>
      <el-row :gutter="20">
        <el-col :span="8">
          <div class="grid-content">
            <span class="label">Hourly</span>
            <el-input class="custom-input" v-model="throughput.perHour" placeholder="Please input" style="width: 100px"></el-input>
            <span class="unit">Piece</span>
          </div>
        </el-col>
      </el-row>
    </el-card>

    <!-- Buttons Section -->
    <div class="button-section">
      <el-button type="primary" @click="handleReturn">Return</el-button>
      <el-button type="primary" @click="handleGenerateMap">Next</el-button>
    </div>
    </el-card>

    <Detail ref="DetailRef" title="Map Detail" />
    <ChuteAmountDialog ref="chuteAmountDialog" @go="handleGo" />
  </div>
</template>

<script lang="ts" setup>
import Detail from '/src/views/main/warehouseMap/component/MapDetail.vue'
import ChuteAmountDialog from './component/ChuteAmountDialog.vue';
import {ref, watch} from "vue";
import { ElMessage } from "element-plus";
import {useRoute} from "vue-router";
const route = useRoute()
const warehouse = ref({
  length: undefined,
  width: undefined
});

const goodsSize = ref({
  length: undefined,
  width: undefined
});

const throughput = ref({
  perHour: undefined
});


const DetailRef = ref();
const chuteAmountDialog = ref();

const opendetail = (row: any) => {
  console.log('detail', row);
  DetailRef.value?.openDialog(row);
};

const handleReturn = () => {
  ElMessage('Return button clicked');
};

const handleGenerateMap = () => {
  chuteAmountDialog.value.openDialog(throughput.value);
};
const handleGo = (chuteAmount: number, parkAmount: number,chargePileAmount : number,dispatchAmount : number) => {
  opendetail({
    chuteAmount: Number(chuteAmount),
    parkAmount: Number(parkAmount),
    chargePileAmount: Number(chargePileAmount),
    dispatchAmount: Number(dispatchAmount),
    warehouseWidth: Number(warehouse.value.width),
    warehouseLength: Number(warehouse.value.length),
    goodsWidth: Number(goodsSize.value.width),
    goodsLength: Number(goodsSize.value.length),
    expectedThroughput: Number(throughput.value.perHour)
  })
  // 清空表单
  warehouse.value = {
    length: undefined,
    width: undefined
  };
  goodsSize.value = {
    length: undefined,
    width: undefined
  };
  throughput.value = {
    perHour: undefined
  };
};
</script>

<style scoped>
.projectQa-container {

  .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .grid-content {
    display: flex;
    align-items: center;

    .label {
      margin-right: 10px;
      font-weight: bold;
    }

    .unit {
      font-weight: bold;
    }

    /* 自定义输入框样式 */
    .custom-input ::v-deep(.el-input__inner) {
      text-align: center; /* 文本居中 */
      border: none; /* 去掉边框 */
      outline: none; /* 去掉聚焦时的轮廓线 */
      background-color: transparent; /* 背景透明 */
    }
  }

  .button-section {
    text-align: right;
    margin-top: 20px;
  }
}
</style>
